<?php

// Namespace

namespace Loop;


/**
 * CSessionManager is a class that takes care of user sessions
 */

class CSessionManager
{
	// Properties
	
	private $coreSession = null;
	
	
	/**
	 * Initializes the session manager, i.e. creates or loads a session for the current user
	 * Note that in initialization functions we try to avoid using proxy functions as they might involve deadlocks
	 */
	
	public function initialize()
	{
		// Make sure that the place where sessions are stored exists
		
		$path = path
		(
			array
			(
				PATH_TEMPORARY,
				'Session'
			),
			true,
			false
		);
		
		
		// Sessions are stored here
		
		session_save_path($path);

		
		// Start the session
		
		session_start();
	}
	
	
	/**
	 * Clears the session
	 */
	
	public function reset()
	{
		session_unset();
		session_destroy();
		
		setcookie('sessionKey', '');
	}
}

?>
